﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Lon.Server
{
    public partial class UserLogForm : Form
    {
        public UserLogForm()
        {
            InitializeComponent();
        }

     

        protected override void OnLoad(EventArgs e)
        {
        
            
            FillGrid();

            base.OnLoad(e);
        }

        protected override void OnClientSizeChanged(EventArgs e)
        {
            ResizeGrid();
            base.OnClientSizeChanged(e);
        }

        void FillGrid()
        {
            DataTable dt = QueryUserLogTable(DateTime.MinValue, DateTime.MaxValue);
            if (dt != null)
            {
                dataGridView1.DataSource = dt;
                ResizeGrid();
            }
        }

        private DataTable QueryUserLogTable(DateTime dateTime, DateTime dateTime_2)
        {
            return null;
        }

        void ResizeGrid()
        {
            if (dataGridView1.DataSource != null)
            {
                DataTable dt = (DataTable)dataGridView1.DataSource;

                int cellWidth = (this.dataGridView1.ClientRectangle.Width - dt.Columns.Count - 18) / dt.Columns.Count;

                for (int i = 0; i < this.dataGridView1.Columns.Count; i++)
                {
                    this.dataGridView1.Columns[i].Width = cellWidth;
                }

            }
        }

    }
}
